﻿using com.guojin.core.io;
using com.guojin.core.io.message;

namespace com.guojin.mj.net.message.game
{
    //同步游戏信息
    public class GameUserInfoRet : Message
    {
        public static int TYPE = 12;
        public static int ID = 8;

        public string userName { get; set; }
        public string avatar { get; set; }
        public int sex { get; set; }
        public int gold { get; set; }
        public int totalScore { get; set; }
        public int locationIndex { get; set; }
        public int userId { get; set; }
        public string ip { get; set; }
        public bool isMiddleJoin { get; set; }
        public bool online { get; set; }
        public string longitude { get; set; }
        public string latitude { get; set; }
        public string approver { get; set; }


        public void decode(Input _in)
        {
            userName = _in.readString();
            avatar = _in.readString();
            sex = _in.readInt();
            gold = _in.readInt();
            totalScore = _in.readInt();
            locationIndex = _in.readInt();
            userId = _in.readInt();
            ip = _in.readString();
            isMiddleJoin = _in.readBoolean();
            online = _in.readBoolean();
            longitude = _in.readString();
            latitude = _in.readString();
            approver = _in.readString();
        }

        public void encode(Output _out)
        {
        }

        public int getMessageId()
        {
            return ID;
        }

        public int getMessageType()
        {
            return TYPE;
        }

        public string toString()
        {
            return "GameUserInfoRet [userName=" + userName + ",avatar=" + avatar + ",sex=" + sex + ",roomCardTex=" + gold +
                   ",userTotalScore=" + totalScore + ",locationIndex=" + locationIndex + ",UserId=" + userId + ",ip=" + ip
                  + ", isMiddleJoin= " + isMiddleJoin + ",online=" + online+ "longitude=" +
                   longitude + "latitude= " + latitude + "approver= "+approver+ ", ]";
        }

        public static  GameUserInfoRet Create(Player player)
        {
            GameUserInfoRet gu = new GameUserInfoRet();
            gu.userName = player.userName;
            gu.avatar = player.avatar;
            gu.sex = player.sex;
            gu.gold = player.gold;
            gu.totalScore = player.TotalScore;
            gu.locationIndex = player.locationIndex;
            gu.userId = player.userId;
            gu.ip = player.ip;
            gu.isMiddleJoin = player.isMiddleJoin;
            gu.online = player.online;
            gu.longitude = player.longitude;
            gu.latitude = player.latitude;
            gu.approver = player.approver;
            return gu;
        }

    }
}